package com.example.babyapp;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class SecondInfoActivity extends Activity{
	
	public void onCreate(Bundle bundle){
		super.onCreate(bundle);
		setContentView(R.layout.activity_secondinfo);
		setOrientation();
	}
	
	public void gotoOtherInfoActivity(View view){
		Intent intent = new Intent(this, OtherInfoActivity.class);
		Intent intentTwo = getIntent();
		String[] babyInfo = intentTwo.getStringArrayExtra("babyInfo");
		
		EditText txtMotherName = (EditText) findViewById(R.id.nomField);
		EditText txtMotherFName = (EditText) findViewById(R.id.nomField2);
		EditText txtFatherName = (EditText) findViewById(R.id.nofField);
		EditText txtFatherFName = (EditText) findViewById(R.id.nofField2);
		EditText txtContact = (EditText) findViewById(R.id.contactField);
		EditText txtStreet = (EditText) findViewById(R.id.streetField);
		EditText txtCity = (EditText) findViewById(R.id.cityField);
		EditText txtState = (EditText) findViewById(R.id.stateField);
		EditText txtZipCode = (EditText) findViewById(R.id.zipcodeField);
		
		String motherName = txtMotherFName.getText().toString() +" "+ txtMotherName.getText().toString();
		String fatherName = txtFatherFName.getText().toString() +" "+ txtFatherName.getText().toString();
		
		if (txtMotherName == null || txtFatherName == null  || txtContact == null  || txtStreet == null  || 
				txtCity == null  || txtState == null  || txtZipCode == null){
			
			Toast.makeText(getApplicationContext(), "Please Fill up all Fields", Toast.LENGTH_SHORT).show();
			
		} else if (txtMotherName != null || txtFatherName != null  || txtContact != null  || txtStreet != null  || 
				txtCity != null  || txtState != null  || txtZipCode != null) {
			
			String[] secondInfo = { motherName , fatherName, txtContact.getText().toString()
									, txtStreet.getText().toString() , txtCity.getText().toString() , txtState.getText().toString() 
									, txtZipCode.getText().toString() };
			
			intent.putExtra("babyInfo", babyInfo);
			intent.putExtra("secondInfo", secondInfo);
			startActivity(intent);
			
		}
		
	}
	
	protected void setOrientation() {
    	int current = getRequestedOrientation();
    	if(current != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){
    		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    	}
    }

}
